﻿<!--#include file="config.asp"-->
<%
	if not(checkloginstaus) then
		sdcms.echo "0登录失败"
		sdcms.die
	end if
	dim t0:t0=sdcms.getint(sdcms.fget("t0",0),0)
	dim t1:t1=sdcms.getint(sdcms.fget("t1",0),0)
	dim t2:t2=sdcms.enhtml(sdcms.fget("t2",0))
	dim t3:t3=sdcms.enhtml(sdcms.fget("t3",0))
	dim total:total=0
	dim thisnum:thisnum=0
	if t1<=0 then t1=100
	dim isbaidu:isbaidu=false
	dim isgoogle:isgoogle=false
	select case t0
		case "1":isbaidu=true:total=total+1
		case "2":isgoogle=true:total=total+1
		case "0":isbaidu=true:isgoogle=true:total=2
	end select
	dim data,i
	data=sdcms.db.dbload(t1,"id,createdate,catedir,url","sd_content n left join sd_category c on n.classid=c.cateid","islock=1 and isurl=0","id desc")
	if ubound(data)<0 then
		sdcms.die
	end if
	
	if isbaidu then
		dim baidustr_01,baidustr,baidustr_02
		baidustr_01=baidustr_01&"<?xml version=""1.0"" encoding=""utf-8""?>"&vbcrlf
		baidustr_01=baidustr_01&"<urlset>"&vbcrlf
		baidustr=baidustr&"    <url>"&vbcrlf
		baidustr=baidustr&"        <loc>{loc}</loc>"&vbcrlf
		baidustr=baidustr&"        <lastmod>{lastmod}</lastmod>"&vbcrlf
		baidustr=baidustr&"        <changefreq>"&t2&"</changefreq>"&vbcrlf
		baidustr=baidustr&"        <priority>"&t3&"</priority>"&vbcrlf
		baidustr=baidustr&"    </url>"&vbcrlf
		baidustr_02=baidustr_02&"</urlset>"&vbcrlf
		dim baiduhtml:baiduhtml=""
		dim bstr,loc,lastmod
		for i=0 to ubound(data,2)
			bstr=baidustr
			lastmod=sdcms.getdate(data(1,i),"-",1)
			select case webmode
				case "1"
					loc=weburl&webroot&"show.asp?id="&data(0,i)
				case "2"
					loc=weburl&webroot&data(2,i)&"/"&data(3,i)&".html"
				case "3"
					loc=weburl&webroot&htmldir&data(2,i)&"/"&data(3,i)&".html"
			end select
			bstr=replace(bstr,"{loc}",loc)
			bstr=replace(bstr,"{lastmod}",lastmod)
			baiduhtml=baiduhtml&bstr
		next
		baiduhtml=baidustr_01&baiduhtml&baidustr_02
		dim baiduurl:baiduurl="<a href=../sitemap_baidu.xml target=_blank>百度地图</a>　"
		sdcms.newfile "../../","sitemap_baidu.xml",baiduhtml,""
		thisnum=thisnum+1
	end if
	
	if isgoogle then
		dim googlestr_01,googlestr,googlestr_02
		googlestr_01=googlestr_01&"<?xml version=""1.0"" encoding=""utf-8""?>"&vbcrlf
		googlestr_01=googlestr_01&"<urlset xmlns=""http://www.sitemaps.org/schemas/sitemap/0.9"">"&vbcrlf
		googlestr=googlestr&"    <url>"&vbcrlf
		googlestr=googlestr&"        <loc>{loc}</loc>"&vbcrlf
		googlestr=googlestr&"        <lastmod>{lastmod}</lastmod>"&vbcrlf
		googlestr=googlestr&"        <changefreq>"&t2&"</changefreq>"&vbcrlf
		googlestr=googlestr&"        <priority>"&t3&"</priority>"&vbcrlf
		googlestr=googlestr&"    </url>"&vbcrlf
		googlestr_02=googlestr_02&"</urlset>"&vbcrlf
		dim googlehtml:googlehtml=""
		dim gstr
		for i=0 to ubound(data,2)
			gstr=googlestr
			lastmod=googledate(data(1,i))
			select case webmode
				case "1"
					loc=weburl&webroot&"show.asp?id="&data(0,i)
				case "2"
					loc=weburl&webroot&data(2,i)&"/"&data(3,i)&".html"
				case "3"
					loc=weburl&webroot&htmldir&data(2,i)&"/"&data(3,i)&".html"
			end select
			gstr=replace(gstr,"{loc}",loc)
			gstr=replace(gstr,"{lastmod}",lastmod)
			googlehtml=googlehtml&gstr
		next
		googlehtml=googlestr_01&googlehtml&googlestr_02
		dim googleurl:googleurl="<a href=../sitemap_google.xml target=_blank>谷歌地图</a>　"
		sdcms.newfile "../../","sitemap_google.xml",googlehtml,""
		thisnum=thisnum+1
	end if
	sdcms.echo "地图生成完毕，总计生成了<span>"&total&"</span>个地图( 点击查看："&baiduurl&googleurl&")"
	sdcms.db.dbclose
%>